package com.lv.entity;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * Created with IntelliJ IDEA.
 * <p>
 *
 * </p>
 *
 * @Author: 凉薄
 * @Date: 2022/01/08/16:29
 * @Description:
 */
@Data
public class LoginUser implements UserDetails {
    private Long id;
    private String username;
    private String password;
    private Integer status;
    private Collection<? extends GrantedAuthority> authorities;

    public LoginUser(Long id, String username, String password, Integer status, Collection<? extends GrantedAuthority> authorities) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.status = status;
        this.authorities = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        if(status==1){
            return true;
        }
        return false;
    }
}
